package cn.edu.tsinghua.thss.alg.closestpair.algorithm;

import java.math.BigDecimal;
import java.util.Random;

public class Rand {

	/**
	 * Generate numerous points randomly.
	 * 
	 * @param size
	 *            the number of points to generate
	 * @return points
	 */

	public static double[][] getRandomPoints(int size) {
		double[][] points = new double[size][2];
		Random random = new Random(200);
		for (int i = 0; i < size; i++) {
			points[i][0] = random.nextDouble();
			points[i][1] = random.nextDouble();
		}

		return points;
	}

	public static double round(double value, int scale, int roundingMode) {
		BigDecimal bd = new BigDecimal(value);
		bd = bd.setScale(scale, roundingMode);
		double d = bd.doubleValue();
		bd = null;
		return d;
	}

}
